﻿using Ext.Net.MVC;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Ext.Net;
using Sharp.Portal;
using Sharp.Portal.Mvc.List;
using Sharp.Portal.Other;
 

namespace Sharp.WebBooter.Areas.Platform.Models
{
    [Title("主数据管理")]
    [DataHandler(ModuleOP.Details, "浏览", 0, UrlAction = "Details")]
    [DataHandler(ModuleOP.Create, "新增", 1)]
    [DataHandler(ModuleOP.Edit, "修改", 2)]
    [DataHandler(ModuleOP.Delete, "删除", 3)]
    [DataHandler(ModuleOP.Refresh, "刷新", 4)]
    public class MasterDataIndexModel : Sharp.Portal.ExtNet.ExtSharpList
    {
        public MasterDataIndexModel()
        {
            this.Feature = ListFeature.MultiSelect | ListFeature.Paging | ListFeature.RowNumber;
            this.ToolbarButtonParameters.Add(new ToolButtonInfo()
            {
                Mode = ModuleOP.Create,
                //Direct = new ToolButtonInfo.DirectClickAction("Create", "MasterData"),
                Parameters = new List<ToolButtonInfo.Parameter>()
                {
                    new ToolButtonInfo.Parameter("Category",
                        "new MasterData().getCategoryValue(this)", (int) ParameterMode.Value)  ,
                    new ToolButtonInfo.Parameter("refreshGrid",
                        "this.up('grid').getId()", (int) ParameterMode.Value)
                }
            });
            this.ImportJavascript = "~/Areas/Platform/Scripts/MasterData.js";
        }

        protected override void InitQueryPanel()
        {
            base.InitQueryPanel();
            this.QueryItems.Add(new QueryItem()
            {
                Text = "分类",
                Name = "Category",
                QueryFeatureOption = QueryFeature.Queryable,
                IsHiddenField = true
            });

        }
        public Guid Id { get; set; }


        /// <summary>
        ///     代码
        /// </summary>
        /// <value>代码</value>
        [Display(Name = "代码"), Ext.Net.MVC.Column(Width = 100, Text = "代码")]
        public string Code { get; set; }

        /// <summary>
        ///     名称
        /// </summary>
        /// <value>名称</value>
        [Display(Name = "名称"), Ext.Net.MVC.Column(Width = 150, Text = "名称"), QueryOption(Option = QueryFeature.DefualtQuery)]
        public string Name { get; set; }

        /// <summary>
        ///     父Id
        /// </summary>
        /// <value>父Id</value>
        [Display(Name = "父Id")]
        public string ParentId { get; set; }

        /// <summary>
        ///     全称
        /// </summary>
        [Display(Name = "全称"), Ext.Net.MVC.Column(Width = 300, Text = "全称")]
        public string FullName { get; set; }

        /// <summary>
        ///     简称
        /// </summary>
        [Display(Name = "简称"), Ext.Net.MVC.Column(Width = 100, Text = "简称")]
        public string Abbreviation { get; set; }


        /// <summary>
        ///     左边树形菜单
        /// </summary>
        public Node LeftTree { get; set; }

    }
}